<div class="inmodal">
    <div class="modal-header">
        <h4 class="modal-title">{{operation | translate}}(ID:{{space.id}})</h4>
    </div>
    <div class="modal-body">
        <form role="form" name="form_space" novalidate class="form-horizontal">
            <div class="form-group">
                <label class="col-sm-4 control-label">{{'SETTING.NAME' | translate}}</label>
                <div class="col-sm-8">
                    <input ng-model="space.name" type="text" name="spacename" class="form-control" required>
                    <div class="m-t-xs" ng-show="form_space.spacename.$invalid && form_space.spacename.$dirty">
                        <small class="text-danger"
                            ng-show="form_space.spacename.$error.required">{{'SETTING.INPUT_NAME' | translate}}</small>
                    </div>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <label class="col-sm-4 control-label">{{'SPACE.AREA' | translate}}</label>
                <div class="col-sm-8">
                    <input ng-model="space.area" type="number" name="spacearea" class="form-control" required>
                    <div class="m-t-xs" ng-show="form_space.spacearea.$invalid && form_space.spacearea.$dirty">
                        <small class="text-danger"
                            ng-show="form_space.spacearea.$error.required">{{'SPACE.INPUT_AREA' | translate}}</small>
                        <small class="text-danger"
                            ng-show="form_space.spacearea.$error">{{'SETTING.INVALID_FORMAT' | translate}}</small>
                    </div>
                </div>
            </div>

            <div class="form-group"><label class="col-sm-4 control-label">{{'SETTING.CONTACT' | translate}} ({{'SETTING.OPTIONAL' | translate}})</label>
                <div class="col-sm-8">
                    <ui-select ng-model="space.contact.id" name="spacecontact" theme="bootstrap">
                        <ui-select-match allow-clear="true" placeholder="{{'COMMON.PLACEHOLDER' | translate}}">
                            {{$select.selected.name}}</ui-select-match>
                        <ui-select-choices repeat="contact.id as contact in contacts | filter: $select.search">
                            <div ng-bind-html="contact.name | highlight: $select.search"></div>
                            <small>{{contact.email}},{{contact.phone}}</small>
                        </ui-select-choices>
                    </ui-select>
                    <div class="m-t-xs" ng-show="form_space.spacecontact.$invalid && form_space.spacecontact.$dirty">
                        <small class="text-danger"
                            ng-show="form_space.spacecontact.$error.required">{{'SETTING.SELECT_CONTACT' | translate}}</small>
                    </div>
                </div>
            </div>

            <div class="form-group"><label class="col-sm-4 control-label">{{'SETTING.TIMEZONE' | translate}}</label>
                <div class="col-sm-8">
                    <ui-select ng-model="space.timezone.id" name="spacetimezone" theme="bootstrap" required>
                        <ui-select-match allow-clear="false" placeholder="{{'COMMON.PLACEHOLDER' | translate}}">
                            {{$select.selected.name}}</ui-select-match>
                        <ui-select-choices repeat="timezone.id as timezone in timezones | filter: $select.search">
                            <div ng-bind-html="timezone.name | highlight: $select.search"></div>
                            <small>{{timezone.description}}</small>
                        </ui-select-choices>
                    </ui-select>
                    <div class="m-t-xs" ng-show="form_space.spacetimezone.$invalid && form_space.spacetimezone.$dirty">
                        <small class="text-danger"
                            ng-show="form_space.spacetimezone.$error.required">{{'SETTING.SELECT_TIMEZONE' | translate}}</small>

                    </div>
                </div>
            </div>

            <div class="form-group"><label
                    class="col-sm-4 control-label">{{'SETTING.IS_INPUT_COUNTED' | translate}}</label>

                <div class="col-sm-8">
                    <div class="checkbox checkbox-success">
                        <input id="chk_space_isinputcounted" type="checkbox" ng-model="space.is_input_counted"
                            ng-checked="space.is_input_counted">
                        <label for="chk_space_isinputcounted">{{'SETTING.IS_INPUT_COUNTED' | translate}}</label>
                    </div>

                </div>
            </div>

            <div class="form-group"><label
                    class="col-sm-4 control-label">{{'SETTING.IS_OUTPUT_COUNTED' | translate}}</label>

                <div class="col-sm-8">
                    <div class="checkbox checkbox-success">
                        <input id="chk_space_isoutputcounted" type="checkbox" ng-model="space.is_output_counted"
                            ng-checked="space.is_output_counted">
                        <label for="chk_space_isoutputcounted">{{'SETTING.IS_OUTPUT_COUNTED' | translate}}</label>
                    </div>

                </div>
            </div>

            <div class="form-group"><label class="col-sm-4 control-label">{{'SETTING.COSTCENTER' | translate}}</label>
                <div class="col-sm-8">
                    <ui-select ng-model="space.cost_center.id" theme="bootstrap" required>
                        <ui-select-match allow-clear="flase" placeholder="{{'COMMON.PLACEHOLDER' | translate}}">
                            {{$select.selected.name}}</ui-select-match>
                        <ui-select-choices repeat="costcenter.id as costcenter in costcenters | filter: $select.search">
                            <div ng-bind-html="costcenter.name | highlight: $select.search"></div>
                        </ui-select-choices>
                    </ui-select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">{{'SPACE.GET_COORDINATE' | translate}}</label>
                <div class="col-sm-8">
                    <a class="btn btn-primary btn-rounded btn-outline" href="https://docs.mapbox.com/playground/geocoding-v6/" target="_blank">Mapbox</a>
                    <a class="btn btn-primary btn-rounded btn-outline" href="https://www.google.com/maps" target="_blank">Google Maps</a>
                </div>
            </div>
            <div class="form-group"><label class="col-sm-4 control-label">{{'SPACE.LATITUDE' | translate}} ({{'SETTING.OPTIONAL' | translate}})</label>
                <div class="col-sm-8">
                    <input ng-model="space.latitude" type="number" name="spacelatitude" class="form-control">
                    <div class="m-t-xs" ng-show="form_space.spacelatitude.$invalid && form_space.spacelatitude.$dirty">
                        <small class="text-danger" ng-show="form_space.spacelatitude.$error.required">{{'SPACE.INPUT_LATITUDE' | translate}}</small>
                        <small class="text-danger" ng-show="form_space.spacelatitude.$error">{{'SETTING.INVALID_FORMAT' | translate}}</small>
                    </div>
                </div>
            </div>
            <div class="form-group"><label class="col-sm-4 control-label">{{'SPACE.LONGITUDE' | translate}} ({{'SETTING.OPTIONAL' | translate}})</label>
                <div class="col-sm-8">
                    <input ng-model="space.longitude" type="number" name="spacelongitude" class="form-control">
                    <div class="m-t-xs" ng-show="form_space.spacelongitude.$invalid && form_space.spacelongitude.$dirty">
                        <small class="text-danger" ng-show="form_space.spacelongitude.$error.required">{{'SPACE.INPUT_LONGITUDE' | translate}}</small>
                        <small class="text-danger" ng-show="form_space.spacelongitude.$error">{{'SETTING.INVALID_FORMAT' | translate}}</small>
                    </div>
                </div>
            </div>

            <div class="form-group"><label class="col-sm-4 control-label">{{'SETTING.DESCRIPTION' | translate}} ({{'SETTING.OPTIONAL' | translate}})</label>
                <div class="col-sm-8">
                    <input ng-model="space.description" type="text" name="spacedescription" class="form-control">
                </div>
            </div>
            <div class="form-group" ng-show="space.qrcode"><label class="col-sm-4 control-label">{{'COMMON.QR_CODE' | translate}} </label>
             <div class="col-sm-8">
                  <div>
                       <qrcode data="{{space.qrcode}}" version="1" error-correction-level="L" size="100" color="#fff" background="#000" download></qrcode>
                  </div>
              </div>
            </div>
        </form>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-white" ng-click="cancel()">{{'SETTING.CANCEL' | translate}}</button>
        <button type="button" ng-disabled="form_space.$invalid" class="btn btn-primary"
            ng-click="ok()">{{'SETTING.SAVE' | translate}}</button>
    </div>
</div>